﻿import QtQuick 2.4
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3


Rectangle {
    id:windControler
    width: 300
    height: 230
    color: "#CC333333"
    radius: 5
    transform: Scale { origin.x: 0; origin.y: 0; xScale: root.x_enl-0.3;yScale: root.y_enl-0.3}
    Text{
        x: 20
        y: 20
        width: 300
        height: 30
        text:"矢量风场"
        font.family: "黑体"
        color: "white";
    }
    Rectangle{
        x:10
        y:40
        width: 280
        height: 1
        radius: 1
        color: "#FFCCCCCC"
    }

    RowLayout {
        x: 20
        y: 50
        width: 260
        height: 30
        Text{
            text:"模式:"
            color: "white";
            font.family: "黑体"
        }

        ExclusiveGroup { id: tabPositionGroup }
        Component{

            id: myRadioButtonStyle;
            RadioButtonStyle{

                indicator: Rectangle{
                    implicitHeight: 16;
                    implicitWidth: 16;
                    radius: 7;
                    Rectangle{
                        anchors.fill: parent;
                        visible: control.checked;
                        color:"#000000";
                        radius: 6;
                        anchors.margins: 2;
                    }
                }
                label:Text{
                    color: "white";
                    text:control.text;
                }
            }
        }
        RadioButton {
            text: "实时"
            checked: true
            style:myRadioButtonStyle
            exclusiveGroup: tabPositionGroup
            onClicked:{
                dateComboBox.reals();
            }
        }
        RadioButton {
            text: "预测"
            style:myRadioButtonStyle
            exclusiveGroup: tabPositionGroup
            onClicked:{
                dateComboBox.forecast()
            }
        }
    }

    RowLayout {
        y:90
        x:20
        width: 260
        height: 30
        Text{
            color: "white";
            text:"时间:"
            font.family: "黑体"
        }
        Item{
            width: 200
            height: 25
            ComboBox {
                id:wind_combobox
                property bool isreal: true
                //anchors.right: parent.right
                anchors.fill: parent
                model: ListModel{
                    id:dateComboBox

                    property var reals: function(){
                        wind_combobox.isreal = true;
                        var tstr = app.slotGetWindTimes(1);
                        var arr = JSON.parse(tstr);
                        if(arr.length > 0){
                            dateComboBox.clear();
                            for(var i=0;i < arr.length;i++){
                                dateComboBox.append({"name":arr[i]})
                            }
                        }
                    }
                    property var forecast: function(){
                        wind_combobox.isreal = false;
                        var tstr = app.slotGetWindTimes(2);
                        var arr = JSON.parse(tstr);
                        if(arr.length > 0){
                            dateComboBox.clear();
                            for(var i=0;i < arr.length;i++){
                                dateComboBox.append({"name":arr[i]})
                            }
                        }
                    }
                    Component.onCompleted:
                    {
                        dateComboBox.reals();
                    }
                }

            }
        }
    }
    RowLayout{
        y:135
        x:20
        Text{
            id: text_wind_jw
            color: "white";
            text:"经度:- 纬度-"
            font.family: "黑体"
        }
    }
    RowLayout{
        y:165
        x:20
        Text{
            id: text_wind_ff
            color: "white";
            text:"风速:-m/s 风向:-"
            font.family: "黑体"
        }
    }
    Connections {
        target: app
        onSignalUpdateWindMapQuery:{
            var arr = info.split("+");
            text_wind_jw.text = arr[0]
            text_wind_ff.text = arr[1]
        }
    }

    RowLayout {
        y:195
        x:41
        width: 229
        height: 30
        Rectangle {
            width: 60
            height: 25
            color: "#DDCCCCCC"
            radius: 3
            Text{
                anchors.centerIn: parent
                text:"确定"
                font.family: "黑体"
            }
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    parent.color = "#FF888888"
                    cursorShape = Qt.PointingHandCursor
                }
                onExited: {
                    parent.color = "#DDCCCCCC"
                    cursorShape = Qt.ArrowCursor
                }
                onClicked: {
                    var str = wind_combobox.currentText;

                    app.slotShowWindMap(str,wind_combobox.isreal);
                }
            }
        }
        Item{
            width: 30
            height: 25
        }
        Rectangle {
            width: 60
            height: 25
            color: "#DDCCCCCC"
            radius: 3
            Text{
                anchors.centerIn: parent
                text:"关闭"
                font.family: "黑体"
            }
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    parent.color = "#FF888888"
                    cursorShape = Qt.PointingHandCursor
                }
                onExited: {
                    parent.color = "#DDCCCCCC"
                    cursorShape = Qt.ArrowCursor
                }
                onClicked: {
                    app.slotCloseWindMap();
                    windControler.visible = false
                }
            }
        }
    }

}

